Fix a serialization error on publish
authorAlex Crichton <alex@alexcrichton.com>
Mon, 22 May 2017 15:56:27 +0000 (08:56 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 22 May 2017 20:16:53 +0000 (13:16 -0700)
In TOML we have to emit all keys before we emit all sub-tables, so to handle
that for dependencies just transform everything to an elaborated version.

Closes #4081

src/cargo/util/toml.rs
tests/package.rs

index 0c0646fe25ef0b794b16f964e9d3a7555cd0d966..7d8cc16cea6ca70eb2b233de3b900d6f96700ca4 100644 (file)
@@ -656,7 +656,10 @@ impl TomlManifest {
                     TomlDependency::Detailed(d)
                 }
                 TomlDependency::Simple(ref s) => {
-                    TomlDependency::Simple(s.clone())
+                    TomlDependency::Detailed(DetailedTomlDependency {
+                        version: Some(s.clone()),
+                        ..Default::default()
+                    })
                 }
             }
         }
index 540c66c57d0f3efe794bc0c677ca772e28ddf490..1777235e1cfd9083c33f6d2dbf16d54da1165264 100644 (file)
@@ -12,6 +12,7 @@ use std::path::{Path, PathBuf};
 
 use cargotest::{cargo_process, process};
 use cargotest::support::{project, execs, paths, git, path2url, cargo_exe};
+use cargotest::support::registry::Package;
 use flate2::read::GzDecoder;
 use hamcrest::{assert_that, existing_file, contains, equal_to};
 use tar::Archive;
@@ -663,6 +664,7 @@ fn ignore_workspace_specifier() {
             [project]
             name = "foo"
             version = "0.0.1"
+
             authors = []
 
             [workspace]
@@ -714,3 +716,24 @@ version = "0.1.0"
 authors = []
 "#));
 }
+
+#[test]
+fn package_two_kinds_of_deps() {
+    Package::new("other", "1.0.0").publish();
+    Package::new("other1", "1.0.0").publish();
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies]
+            other = "1.0"
+            other1 = { version = "1.0" }
+        "#)
+        .file("src/main.rs", "");
+
+    assert_that(p.cargo_process("package").arg("--no-verify"),
+                execs().with_status(0));
+}